// JavaScript Document
// calls php page for variable value, brings in an "=" sign separated string

// 	GLOBAL VARIABLES
// DATA
var pageDataElements = new Array();
// DATE						
var pageDateElements = new Array();
// TREND						
var pageTrendElements = new Array();
//General
var pageElements = new Array("nation_employment", "nation_unemployment", "nation_inflation", 
							 "nation_gdp", "nation_consumerConfidence", "nation_caseShillerIndex", 
							 "nation_rates", "nation_permits", "nation_crudeOil", 
							 "nation_gas", "nation_gold", "nation_tenYearTreasury",
							 "nation_usDollarIndex", 
							 
							 "florida_employment", "florida_unemployment", 
							 "florida_freddieMacHousePriceIndex", "florida_consumerConfidenceIndex", "florida_unleadedGasolinePrices", 
							 
							 "crestview_employment", "crestview_unemployment", "crestview_flBedTax",
							 "crestview_automobile", "crestview_durableGoods", "crestview_tourism",
							 "crestview_nondurableGoods", "crestview_construction", "crestview_business",							 
							 "crestview_retailIndex",
							 
							 "panamaCity_employment", "panamaCity_unemployment", "panamaCity_flBedTax",
							 "panamaCity_automobile", "panamaCity_durableGoods", "panamaCity_tourism",
							 "panamaCity_nondurableGoods", "panamaCity_construction", "panamaCity_business",							 
							 "panamaCity_retailIndex",
							  
							 "pensacola_employment", "pensacola_unemployment", "pensacola_flBedTax",
							 "pensacola_automobile", "pensacola_durableGoods", "pensacola_tourism",
							 "pensacola_nondurableGoods", "pensacola_construction", "pensacola_business",							 
							 "pensacola_retailIndex",
							  
							 "tallahassee_employment", "tallahassee_unemployment", "tallahassee_automobile", 
							 "tallahassee_durableGoods", "tallahassee_tourism", "tallahassee_nondurableGoods", 
							 "tallahassee_construction", "tallahassee_business", "tallahassee_retailIndex", 
							 
							 "daytonaBeach_employment", "daytonaBeach_unemployment", "daytonaBeach_automobile", 
							 "daytonaBeach_durableGoods", "daytonaBeach_tourism", "daytonaBeach_nondurableGoods", 
							 "daytonaBeach_construction", "daytonaBeach_business", "daytonaBeach_retailIndex",  
							 
							 "gainesville_employment", "gainesville_unemployment", "gainesville_automobile", 
							 "gainesville_durableGoods", "gainesville_tourism", "gainesville_nondurableGoods", 
							 "gainesville_construction", "gainesville_business", "gainesville_retailIndex",
							  
							 "jacksonville_employment", "jacksonville_unemployment", "jacksonville_automobile", 
							 "jacksonville_durableGoods", "jacksonville_tourism", "jacksonville_nondurableGoods", 
							 "jacksonville_construction", "jacksonville_business", "jacksonville_retailIndex", 
							 
							 "ocala_employment", "ocala_unemployment", "ocala_automobile", 
							 "ocala_durableGoods", "ocala_tourism", "ocala_nondurableGoods", 
							 "ocala_construction", "ocala_business", "ocala_retailIndex",
							 
							 "palmCoast_employment", "palmCoast_unemployment", "palmCoast_automobile", 
							 "palmCoast_durableGoods", "palmCoast_tourism", "palmCoast_nondurableGoods", 
							 "palmCoast_construction", "palmCoast_business", "palmCoast_retailIndex",
							  
							 "orlando_employment", "orlando_unemployment", "orlando_automobile", 
							 "orlando_durableGoods", "orlando_tourism", "orlando_nondurableGoods", 
							 "orlando_construction", "orlando_business", "orlando_retailIndex",
							 
							 "palmBay_employment", "palmBay_unemployment", "palmBay_automobile", 
							 "palmBay_durableGoods", "palmBay_tourism", "palmBay_nondurableGoods", 
							 "palmBay_construction", "palmBay_business", "palmBay_retailIndex",
							  
							 "tampa_employment", "tampa_unemployment", "tampa_automobile", 
							 "tampa_durableGoods", "tampa_tourism", "tampa_nondurableGoods", 
							 "tampa_construction", "tampa_business", "tampa_retailIndex", 
							 
							 "winterHaven_employment", "winterHaven_unemployment", "winterHaven_automobile", 
							 "winterHaven_durableGoods", "winterHaven_tourism", "winterHaven_nondurableGoods", 
							 "winterHaven_construction", "winterHaven_business", "winterHaven_retailIndex", 
							 
							 "veroBeach_employment", "veroBeach_unemployment", "veroBeach_automobile", 
							 "veroBeach_durableGoods", "veroBeach_tourism", "veroBeach_nondurableGoods", 
							 "veroBeach_construction", "veroBeach_business", "veroBeach_retailIndex", 
							 
							 "fortMyers_employment", "fortMyers_unemployment", "fortMyers_automobile", 
							 "fortMyers_durableGoods", "fortMyers_tourism", "fortMyers_nondurableGoods", 
							 "fortMyers_construction", "fortMyers_business", "fortMyers_retailIndex",
							  
							 "miami_employment", "miami_unemployment", "miami_automobile", 
							 "miami_durableGoods", "miami_tourism", "miami_nondurableGoods", 
							 "miami_construction", "miami_business", "miami_retailIndex", 
							 
							 "naples_employment", "naples_unemployment", "naples_automobile", 
							 "naples_durableGoods", "naples_tourism", "naples_nondurableGoods", 
							 "naples_construction", "naples_business", "naples_retailIndex", 
							 
							 "portStLucie_employment", "portStLucie_unemployment", "portStLucie_automobile", 
							 "portStLucie_durableGoods", "portStLucie_tourism", "portStLucie_nondurableGoods", 
							 "portStLucie_construction", "portStLucie_business", "portStLucie_retailIndex",
							  
							 "puntaGorda_employment", "puntaGorda_unemployment", "puntaGorda_automobile", 
							 "puntaGorda_durableGoods", "puntaGorda_tourism", "puntaGorda_nondurableGoods", 
							 "puntaGorda_construction", "puntaGorda_business", "puntaGorda_retailIndex", 
							 
							 "sarasota_employment", "sarasota_unemployment", "sarasota_automobile", 
							 "sarasota_durableGoods", "sarasota_tourism", "sarasota_nondurableGoods", 
							 "sarasota_construction", "sarasota_business", "sarasota_retailIndex");
//Concatenate strings into IDs
createIds();


//Fill page list items with datahttp://haas.uwf.edu:20000/appTrend/AppTrend.aspx
$.get('http://haas.uwf.edu:20000/appTrend/AppTrend.aspx', function (data)
{
	// string is separated into an array
	// breaking up data(string)=date~FL1~FL2(strings associated with columns) each string then converted into array
	var splitColumns = data.split("~");
	var i;
	var tempData;
	
	for(i=0; i<pageDataElements.length; i++)
	{
		tempData = splitColumns[i].split("=");
		
		document.getElementById(pageDateElements[i]).innerHTML = tempData[0];
		document.getElementById(pageDataElements[i]).innerHTML = tempData[1];
		
		var identify = pageTrendElements[i].split("_");
		
		if(identify[1] == "unemployment")
		{
			if (tempData[2] > 0) 
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-up  upgR";	//icon-2x
			}
			else if(tempData[2] == 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-minus-sign  upgB";
			}
			else if(tempData[2] < 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-down  upgG";
			}
		}
		else
		{
		
			if (tempData[2] > 0) 
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-up  upgG";	//icon-2x
			}
			else if(tempData[2] == 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-minus-sign  upgB";
			}
			else if(tempData[2] < 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-down  upgR";
			}
		}
	}
	
	
}
)
// checks connection, displays warnings	
.error(function() 
{
	
	for(i=0; i<pageDataElements.length; i++)
	{
		
		document.getElementById(pageDateElements[i]).innerHTML = "Check your internet connection!";
		
		document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-remove-sign  upgError";
		
	}
		
		
}// End connection check	
);




function createIds()
{
	var i=0;
	
	
	for(i=0; i<pageElements.length; i++)
	{
		pageDataElements.push(pageElements[i]+"_data");
		pageDateElements.push(pageElements[i]+"_date");
		pageTrendElements.push(pageElements[i]+"_trend");
	}
}











//	END GLOBAL VARIABLES

/*var pageDataElements = new Array("nation_employment_data", "nation_unemployment_data", "nation_inflation_data", 
								 "nation_gdp_data", "nation_consumerConfidence_data", "nation_caseShillerIndex_data", 
								 "nation_rates_data", "nation_permits_data", "nation_crudeOil_data", 
								 "nation_gas_data", "nation_gold_data", "nation_tenYearTreasury_data",
								 "nation_usDollarIndex_data", "florida_employment_data", "florida_unemployment_data", 
								 "florida_freddieMacHousePriceIndex_data", "florida_consumerConfidenceIndex_data", "florida_unleadedGasolinePrices_data", 
								 "crestview_employment_data", "crestview_unemployment_data", "crestview_flBedTax_data", 
								 "panamaCity_employment_data", "panamaCity_unemployment_data", "panamaCity_flBedTax_data", 
								 "pensacola_employment_data", "pensacola_unemployment_data", "pensacola_flBedTax_data", 
								 "tallahassee_employment_data", "tallahassee_unemployment_data", "daytonaBeach_employment_data", 
								 "daytonaBeach_unemployment_data", "gainesville_employment_data", "gainesville_unemployment_data", 
								 "jacksonville_employment_data", "jacksonville_unemployment_data", "ocala_employment_data", 
								 "ocala_unemployment_data", "palmCoast_employment_data", "palmCoast_unemployment_data", 
								 "orlando_employment_data", "orlando_unemployment_data", "palmBay_employment_data", 
								 "palmBay_unemployment_data", "tampa_employment_data", "tampa_unemployment_data", 
								 "winterHaven_employment_data", "winterHaven_unemployment_data", "veroBeach_employment_data", 
								 "veroBeach_unemployment_data", "fortMyers_employment_data", "fortMyers_unemployment_data", 
								 "miami_employment_data", "miami_unemployment_data", "naples_employment_data", 
								 "naples_unemployment_data", "portStLucie_employment_data", "portStLucie_unemployment_data", 
								 "puntaGorda_employment_data", "puntaGorda_unemployment_data", "sarasota_employment_data", 
								 "sarasota_unemployment_data");
// DATE						
var pageDateElements = new Array("nation_employment_date", "nation_unemployment_date", "nation_inflation_date", 
								 "nation_gdp_date", "nation_consumerConfidence_date", "nation_caseShillerIndex_date", 
								 "nation_rates_date", "nation_permits_date", "nation_crudeOil_date", 
								 "nation_gas_date", "nation_gold_date", "nation_tenYearTreasury_date", 
								 "nation_usDollarIndex_date", "florida_employment_date", "florida_unemployment_date", 
						         "florida_freddieMacHousePriceIndex_date", "florida_consumerConfidenceIndex_date", "florida_unleadedGasolinePrices_date", 
								 "crestview_employment_date", "crestview_unemployment_date", "crestview_flBedTax_date", 
								 "panamaCity_employment_date", "panamaCity_unemployment_date", "panamaCity_flBedTax_date", 
								 "pensacola_employment_date", "pensacola_unemployment_date", "pensacola_flBedTax_date", 
								 "tallahassee_employment_date", "tallahassee_unemployment_date", "daytonaBeach_employment_date", 
								 "daytonaBeach_unemployment_date", "gainesville_employment_date", "gainesville_unemployment_date",
								 "jacksonville_employment_date", "jacksonville_unemployment_date", "ocala_employment_date", 
								 "ocala_unemployment_date", "palmCoast_employment_date", "palmCoast_unemployment_date", 
								 "orlando_employment_date", "orlando_unemployment_date", "palmBay_employment_date", 
								 "palmBay_unemployment_date", "tampa_employment_date", "tampa_unemployment_date", 
								 "winterHaven_employment_date", "winterHaven_unemployment_date", "veroBeach_employment_date", 
								 "veroBeach_unemployment_date", "fortMyers_employment_date", "fortMyers_unemployment_date", 
								 "miami_employment_date", "miami_unemployment_date", "naples_employment_date", 
								 "naples_unemployment_date", "portStLucie_employment_date", "portStLucie_unemployment_date", 
								 "puntaGorda_employment_date", "puntaGorda_unemployment_date", "sarasota_employment_date", 
								 "sarasota_unemployment_date");
// TREND						
var pageTrendElements = new Array("nation_employment_trend", "nation_unemployment_trend", "nation_inflation_trend", 
								  "nation_gdp_trend", "nation_consumerConfidence_trend", "nation_caseShillerIndex_trend", 
								  "nation_rates_trend", "nation_permits_trend", "nation_crudeOil_trend", 
								  "nation_gas_trend", "nation_gold_trend","nation_tenYearTreasury_trend", 
								  "nation_usDollarIndex_trend","florida_employment_trend", "florida_unemployment_trend", 
								  "florida_freddieMacHousePriceIndex_trend", "florida_consumerConfidenceIndex_trend", "florida_unleadedGasolinePrices_trend", 
								  "crestview_employment_trend", "crestview_unemployment_trend", "crestview_flBedTax_trend", 
								  "panamaCity_employment_trend", "panamaCity_unemployment_trend", "panamaCity_flBedTax_trend", 
								  "pensacola_employment_trend", "pensacola_unemployment_trend", "pensacola_flBedTax_trend", 
								  "tallahassee_employment_trend", "tallahassee_unemployment_trend", "daytonaBeach_employment_trend", 
								  "daytonaBeach_unemployment_trend", "gainesville_employment_trend", "gainesville_unemployment_trend", 
								  "jacksonville_employment_trend", "jacksonville_unemployment_trend", "ocala_employment_trend", 
								  "ocala_unemployment_trend", "palmCoast_employment_trend", "palmCoast_unemployment_trend", 
								  "orlando_employment_trend", "orlando_unemployment_trend", "palmBay_employment_trend", 
								  "palmBay_unemployment_trend", "tampa_employment_trend", "tampa_unemployment_trend", 
								  "winterHaven_employment_trend", "winterHaven_unemployment_trend", "veroBeach_employment_trend", 
								  "veroBeach_unemployment_trend", "fortMyers_employment_trend", "fortMyers_unemployment_trend", 
								  "miami_employment_trend", "miami_unemployment_trend", "naples_employment_trend", 
								  "naples_unemployment_trend", "portStLucie_employment_trend", "portStLucie_unemployment_trend", 
								  "puntaGorda_employment_trend", "puntaGorda_unemployment_trend", "sarasota_employment_trend", 
								  "sarasota_unemployment_trend");*/